#二重循环
s=0
for i in range(1,51):
    product=1
    for j in range(2,i+1):
        product*=j
    s+=product
print(s)

#一重循环
item,s=1,0
for i in range(1,51):
    item*=i
    s+=item
print(s)